package com.ruoyi.fees.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fees.domain.Fees;
import com.ruoyi.fees.service.IFeesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 杂费管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-13
 */
@RestController
@RequestMapping("/fees/fees")
public class FeesController extends BaseController
{
    @Autowired
    private IFeesService feesService;

    /**
     * 查询杂费管理列表
     */
    @PreAuthorize("@ss.hasPermi('fees:fees:list')")
    @GetMapping("/list")
    public TableDataInfo list(Fees fees)
    {
        startPage();
        List<Fees> list = feesService.selectFeesList(fees);
        return getDataTable(list);
    }

    /**
     * 导出杂费管理列表
     */
    @PreAuthorize("@ss.hasPermi('fees:fees:export')")
    @Log(title = "杂费管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Fees fees)
    {
        List<Fees> list = feesService.selectFeesList(fees);
        ExcelUtil<Fees> util = new ExcelUtil<Fees>(Fees.class);
        util.exportExcel(response, list, "杂费管理数据");
    }

    /**
     * 获取杂费管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('fees:fees:query')")
    @GetMapping(value = "/{feeId}")
    public AjaxResult getInfo(@PathVariable("feeId") Long feeId)
    {
        return success(feesService.selectFeesByFeeId(feeId));
    }

    /**
     * 新增杂费管理
     */
    @PreAuthorize("@ss.hasPermi('fees:fees:add')")
    @Log(title = "杂费管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Fees fees)
    {
        return toAjax(feesService.insertFees(fees));
    }

    /**
     * 修改杂费管理
     */
    @PreAuthorize("@ss.hasPermi('fees:fees:edit')")
    @Log(title = "杂费管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Fees fees)
    {
        return toAjax(feesService.updateFees(fees));
    }

    /**
     * 删除杂费管理
     */
    @PreAuthorize("@ss.hasPermi('fees:fees:remove')")
    @Log(title = "杂费管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feeIds}")
    public AjaxResult remove(@PathVariable Long[] feeIds)
    {
        return toAjax(feesService.deleteFeesByFeeIds(feeIds));
    }
}
